package com.ui;


import com.service.IAccountService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 模拟一个表现层，用于调用业务层
 */
public class Client {


    public static void main(String[] args) {
        //1.获取核心容器对象
//        ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
        ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");

        //2.根据id获取Bean对象
        IAccountService as = (IAccountService) ac.getBean("accountService");
        // IAccountService as1 = (IAccountService) ac.getBean("accountService");
        // System.out.println(as == as1);
        // as.saveAccount();

//        Object instanceFactory = ac.getBean("accountService2");
//        System.out.println(instanceFactory);
//        //手动关闭容器
        ac.close();
    }
}
